package com.controller.secretary;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.jfinal.core.ActionKey;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.model.Mediumterminspection;
import com.model.PaperKeyTime;

public class keytimeController extends Controller {
	@ActionKey("/secretary-Save")
	public void save(){
		
		Date dt=new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
		String k_b = dateFormat.format(getParaToDate("keytime_begintime"));
		String k_e = dateFormat.format(getParaToDate("keytime_endtime"));
		System.out.println(k_b);
		Record r=new Record().set("keytime_submittime", dt).set("keytime_issueman",getParaToInt("keytime_issueman")).set("keytime_id", getPara("keytime_id")).set("keytime_begintime", k_b).set("keytime_endtime", k_e);
		Db.update("paperkeytime", "keytime_id",r);
		/*int secretary_id=1;
		System.out.println(getPara("keytime_id"));
		if(getParaToInt("keytime_issueman")!=1){
			Record r=new Record().set("keytime_id", getPara("keytime_id")).set("keytime_begintime", getPara("keytime_begintime")).set("keytime_endtime", getPara("keytime_endtime"));
			Db.update("paperkeytime", "keytime_id",r);
		}
		else{
			Record r=new Record().set("keytime_type", getPara("keytime_type")).set("keytime_begintime", getPara("keytime_begintime")).set("keytime_endtime", getPara("keytime_endtime"));
			Db.save("paperkeytime", r);
		}*/
		renderJson("{\"success\":true}");
	}
	@ActionKey("/secretary-keytime")
	public void keytime(){
		String od=getPara("order");
		String sort=getPara("sort");
		//int s_id=getSessionAttr("secretary_id");//通过教学秘书的主键找到他所在的系
		int s_id=209;
		String sql="select * from secretary_3 where keytime_issueman="+s_id+" order by "+sort+" "+od+"";
		List<Record> list=Db.find(sql);
		renderJson(list);
	}
}
